Adding some more judges, here and there.
[and.git] / lib / Mi manual de algoritmos / version_maraton_nacional_2008 / src / misc / parser_recursivo_desc.cpp
bloba2e93ec1623bead7a6260d5a58e66ead76aa3f42
1 //A -> (A)A | Epsilon
3 #include <iostream>
4 #include <string>
6 using namespace std;
8 bool ok;
9 char sgte;
10 int i;
11 string s;
13 bool match(char c){
14 if (sgte != c){
15 ok = false;
17 sgte = s[++i];
20 void A(){
21 if (sgte == '('){
22 match('(');
23 A(); match(')'); A();
24 }else if (sgte == '$' || sgte == ')'){
25 //nada
26 }else{
27 ok = false;
31 int main(){
32 while(getline(cin, s) && s != ""){
33 ok = true;
34 s += '$';
35 sgte = s[(i = 0)];
36 A();
37 if (i < s.length()-1) ok = false; //No consumi toda la cadena
38 if (ok){
39 cout << "Accepted\n";
40 }else{
41 cout << "Not accepted\n";